<template>
	<view class="page">
		<view class="page-ctx">
			<view class="notice-list">
				<view class="notice-item" v-for="(item,index) in notices" :key="index" @click="toDetail(item)">
					<view class="notice-top flex-between">
						<!-- <text>{{ item.title || ''}}</text> -->
						<text>{{ item.created_at || ''}}</text>
					</view>
					<view class="notice-con ellipsis-1">
						{{ item.title || ''}}
					</view>
					<view class="notice-bot flex-between" @click="toDetail(item)">
						<text>查看详情</text>
						<image class="right-ico" src="@/static/notice/right.png"></image>
					</view>
				</view>
			</view>

			<view class="load-more-box" style="margin-top: 50rpx;">
				<u-loadmore :status="notices_loadmore_status" @loadmore="loadMore"/>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				notices: [],
				count: 0,
				pagination: {
					page: 1,
					pageNum: 10
				},
				notices_loadmore_status: 'loadmore', //loadmore  / loading / nomore
			};
		},
		onLoad() {
			this.showLoading();
			this.setView()
		},
		onReachBottom() {
			this.loadMore()
		},

		methods: {
			loadMore() {
				if (this.notices_loadmore_status == 'loadmore') {
					this.notices_loadmore_status = 'loading'
					this.pagination.page++;
					this.query_notice();
				}
			},
		
			initQuery() {
				this.favs = [];
				this.pagination.page = 1;
				this.favs_loadmore_status = 'loadmore'
			},
			

			setView() {
				this.query_notice();
			},
			query_notice() {
				this.$api({
					url: '/getNoticeList',
					method: 'get',
					data: {
						...this.pagination,
						// category_id: 1,
					},
				}).then(res => {
					if (res.code == 200) {
						this.notices = this.notices.concat(res.data.list);
						this.notices_loadmore_status = res.data.count > this.notices.length ? 'loadmore' : 'nomore';
					}
					this.hideLoading()
				})
			},
			toDetail(item) {
				this.toRoute({
					path: '/notice-detail',
					query: {
						id: item.id
					}
				})
			},

		}
	}
</script>

<style>
	page {
		background: #F5F7F9;
	}
</style>

<style lang="scss" scoped>
	.notice-list {
		padding: 16rpx 32rpx;

		.notice-item {
			background: #FFFFFF;
			padding: 0 20rpx;
			margin-bottom: 20rpx;
			border-radius: 20rpx 20rpx 20rpx 20rpx;

			.notice-top {
				padding: 30rpx 0 0 0;


				text {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #AAAAAA;

				}
			}

			.notice-con {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;

				margin-top: 16rpx;
				padding-bottom: 30rpx;
				border-bottom: 1rpx solid #F3F4F8;
			}

			.notice-bot {
				height: 84rpx;

				text {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #7D7D7D;
				}

				image {
					width: 30rpx;
					height: 30rpx;
				}
			}
		}
	}
</style>